﻿using System;
using System.Threading.Tasks;
using WalkingTec.Mvvm.Core;
using HengTong.Model.Db.Hr.Bill;
using UUIDNext;


namespace HengTong.ViewModel.Hr.SysHrPersonEntryBillVms
{
    public partial class SysHrPersonEntryBillVm : BaseCRUDVM<SysHrOnboardingRequestBill>
    {

        public SysHrPersonEntryBillVm()
        {
            SetInclude(x => x.Group);
            SetInclude(x => x.JobPosition);
            SetInclude(x => x.PersonEducations);
            SetInclude(x => x.PersonFamilies);
            SetInclude(x => x.PersonWorks);
        }

        protected override void InitVM()
        {
        }

        public override async Task DoAddAsync()
        {
            Entity.ID = Uuid.NewDatabaseFriendly(Database.SqlServer);
            if (Entity is IBasePoco poco)
            {
                poco.CreateBy = Wtm.LoginUserInfo?.ITCode;
                poco.UpdateBy = Wtm.LoginUserInfo?.ITCode;
                poco.CreateTime = DateTime.Now;
                poco.UpdateTime = DateTime.Now;
            }
            await base.DoAddAsync();
        }

        public override async Task DoEditAsync(bool updateAllFields = false)
        {
            if (Entity is IBasePoco poco)
            {
                poco.UpdateBy = Wtm.LoginUserInfo?.ITCode;
                poco.UpdateTime = DateTime.Now;
            }
            await base.DoEditAsync(updateAllFields);
        }

        public override void DoDelete()
        {
            base.DoDelete();
        }
    }
}
